package com.qys.livesMall;

import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.ServletComponentScan;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.core.env.Environment;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.transaction.annotation.EnableTransactionManagement;

import java.net.InetAddress;
import java.net.UnknownHostException;

/**
 * Created by IntelliJ IDEA.
 * User: dp
 * Date: 2023/05/16
 * Time: 13:44
 * DESCRIPTION:
 */
@Slf4j
@EnableAsync
@EnableScheduling
@ServletComponentScan(basePackages = {"com.qys.livesMall","com.qys.wallet"})
@SpringBootApplication(scanBasePackages = {"com.qys.livesMall","com.qys.wallet"})
@EnableTransactionManagement
public class QysLivesMallApplication {

    public static void main(String[] args) throws UnknownHostException {
        try {
            final ConfigurableApplicationContext application = SpringApplication.run(QysLivesMallApplication.class, args);

            System.out.println("(♥◠‿◠)ﾉﾞ  直播商城系统启动成功   ლ(´ڡ`ლ)ﾞ");
            Environment env = application.getEnvironment();
            String ip = InetAddress.getLocalHost().getHostAddress();
            String port = env.getProperty("server.port");
            String path = env.getProperty("server.servlet.context-path");
            log.info("\n----------------------------------------------------------\n\t" +
                    "Application Housing is running! Access URLs:\n\t" +
                    "Local: \t\thttp://localhost:" + port + path + "/\n\t" +
                    "Swagger-UI: \t\thttp://" + ip + ":" + port + path + "doc.html\n" +
                    "----------------------------------------------------------");
        }catch (Exception e){
            System.out.printf(e.toString());
        }
    }
}
